﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CreateUser.ascx.cs" Inherits="Web.Cms.Users.CreateUser" %>
<%@ Import Namespace="Module.Core.LoginSystem.Commons.Utilities" %>
<%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="radCln" %>

<script type="text/javascript" language="javascript" src="../Scripts/md5.js"></script>

<script language="javascript" type="text/javascript">
    $('#txtUsername').keydown(function (event) {
        switch (event.keyCode) {
            case 13:
                checkExistUser(r)
                break;
        }
    });

    function checkExistUser(_lstUser) {
        var d = document.getElementById('<%= txtUsername.ClientID%>')

        var temp = new Array();
        temp = _lstUser.split(';')

        if (d.value.length >= 4) {
            for (var i = 0; i < temp.length - 1; i++) {
                hash = hex_md5(d.value);

                if (hash == temp[i]) {
                    $('#divExist').show();
                    $('#divValid').hide();
                    $('#divNotEmpty').hide();
                    $('#divValidateServer').hide();

                    break;
                }
                else {
                    $('#divNotEmpty').hide();
                    $('#divExist').hide();
                    $('#divValid').show();
                    $('#divValidateServer').hide();
                }
            }
        }
        else {
            $('#divNotEmpty').show();
            $('#divValid').hide();
            $('#divExist').hide();
            $('#divValidateServer').hide();
        }

    }
</script>

<p class="heading">
    Tạo mới người dùng</p>
<table id="ds" border="0" cellpadding="2" cellspacing="8" style="width: 100%" class="InputBox">
    <tr>
        <td colspan="5" align="left">
            <asp:Button ID="btnBack" SkinID="AdminButtonBack" runat="server" OnClick="btnBack_Click"
                TabIndex="20" /></td>
    </tr>
    <tr>
        <td colspan="5">
            <asp:Label ID="lblUpdateStatus" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td align="right" width="15%" valign="top" >
            Tên truy cập:
        </td>
        <td style="width: 255px; ">
            <asp:TextBox ID="txtUsername" runat="server" Width="150" Height="25" TabIndex="1" onfocus="setBKColor(event);"
                onblur="reSetBKColor(event);" CssClass="inputRequired"></asp:TextBox>
            <a href="javascript:;" tabindex="2" onclick="checkExistUser(_lstUser)" id="checkUser"
                runat="server">Kiểm tra</a>
            <div id="divValidateServer">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Tên không được để trống"
                    ControlToValidate="txtUsername" SetFocusOnError="True" Display="Dynamic" ValidationGroup="groupuser"></asp:RequiredFieldValidator>
                <asp:Label ID="lblValidateAccount" ForeColor="red" runat="server" Visible="false"></asp:Label>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtUsername"
                    Display="Dynamic" ErrorMessage="Tên đăng nhập ít nhất 4 kí tự trở lên!" ValidationExpression="\w{4,30}"
                    ValidationGroup="groupuser"></asp:RegularExpressionValidator>
            </div>
            <div id="divExist" style="display: none;">
                <span style="color: Red;">Tên đăng nhập đã tồn tại!</span>
            </div>
            <div id="divValid" style="display: none;">
                <span style="color: Blue;">Tên hợp lệ!</span>
            </div>
            <div id="divNotEmpty" style="display: none;">
                <span style="color: Red;">Tên đăng nhập ít nhất 4 kí tự trở lên!</span>
            </div>
        </td>
        <td align="right" width="15%" visible="false" runat="server" id="tdGender" >
            Giới tính:</td>
        <td width="50%" >
            <asp:RadioButtonList ID="rdoGender" runat="server" RepeatDirection="Horizontal" TabIndex="9" Visible="false">
                <asp:ListItem Value="0" Selected="True">Nam</asp:ListItem>
                <asp:ListItem Value="1">Nữ</asp:ListItem>
            </asp:RadioButtonList></td>
    </tr>
    <tr>
        <td align="right">
            Mật khẩu:</td>
        <td style="width: 255px">
            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="192px" Height="25" TabIndex="2"
                onfocus="setBKColor(event);" onblur="reSetBKColor(event);" CssClass="inputRequired"></asp:TextBox>
            <div>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Mật khẩu không được để trống!"
                    ControlToValidate="txtPassword" Display="Dynamic" ValidationGroup="groupuser"></asp:RequiredFieldValidator>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"
                    ControlToValidate="txtPasswordConfirm" ErrorMessage="Mật khẩu không trùng nhau"
                    Display="Dynamic" ValidationGroup="groupuser"></asp:CompareValidator></div>
        </td>
        <td align="right" id="tdTel" runat="server" visible="false">
            Điện thoại:</td>
        <td id="tdTelasd" runat="server" visible="false">
            <asp:TextBox onkeypress="return isNumberKey(event)" ID="txtTel" runat="server" Width="192px"
                TabIndex="10" Height="25"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td align="right">
            Xác nhận mật khẩu:</td>
        <td style="width: 255px">
            <asp:TextBox ID="txtPasswordConfirm" onfocus="setBKColor(event);" onblur="reSetBKColor(event);"
                CssClass="inputRequired" runat="server" TextMode="Password" Width="192px" TabIndex="3" Height="25"></asp:TextBox>
            <div>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Mật khẩu không được để trống!"
                    ControlToValidate="txtPasswordConfirm" Display="Dynamic" ValidationGroup="groupuser"></asp:RequiredFieldValidator>
            </div>
        </td>
        <td align="right" id="tdTelasdsd" runat="server" visible="false">
            Di&nbsp; động:
        </td>
        <td id="tdTaael" runat="server" visible="false">
            <asp:TextBox ID="txtMobile" onkeypress="return isNumberKey(event)" runat="server"
                Width="192px" TabIndex="11" Height="25"></asp:TextBox><br />
        </td>
    </tr>
    <tr>
        <td align="right" >
            Email:</td>
        <td style="width: 255px;">
            <asp:TextBox ID="txtEmail" onfocus="setBKColor(event);" onblur="reSetBKColor(event);"
                CssClass="inputRequired" runat="server" Width="192px" TabIndex="4" Height="25"></asp:TextBox>
            <div>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmail"
                    Display="Dynamic" ErrorMessage="Không được để trống!" ValidationGroup="groupuser"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                    Display="Dynamic" ErrorMessage="Email không hợp lệ!" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                    ValidationGroup="groupuser"></asp:RegularExpressionValidator></div>
        </td>
        <td align="right" id="tdTasdfsfel" runat="server" visible="false">
            Số CMTND:</td>
        <td id="tdTe456l" runat="server" visible="false">
            <asp:TextBox ID="txtCmtnd" onkeypress="return isNumberKey(event)" runat="server"
                Width="192px" TabIndex="12"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td align="right">
            Họ đệm:</td>
        <td style="width: 255px;">
            <asp:TextBox ID="txtFirstName" runat="server" Width="192px" TabIndex="5" Height="25"></asp:TextBox></td>
        <td align="right" id="tdTelgf" runat="server" visible="false">
            Nick Yahoo:</td>
        <td id="asdasdwer" runat="server" visible="false">
            <asp:TextBox ID="txtYm" runat="server" Width="192px" TabIndex="13"></asp:TextBox></td>
    </tr>
    <tr>
        <td align="right">
            Tên:</td>
        <td style="width: 255px">
            <asp:TextBox ID="txtLastName" runat="server" Width="192px" TabIndex="6" Height="25"></asp:TextBox></td>
        <td align="right" id="tasdasdasddTel" runat="server" visible="false">
            Nick Skype:</td>
        <td id="tdTkhjkel" runat="server" visible="false">
            <asp:TextBox ID="txtSkype" runat="server" Width="192px" TabIndex="14"></asp:TextBox></td>
    </tr>
    <tr runat="server" id="asd" visible="false">
        <td align="right">
            Ngày&nbsp; sinh:</td>
        <td style="width: 255px">
            <radCln:RadDatePicker ID="radBirth" runat="server" TabIndex="7" Width="200px">
                <DateInput Title="Ng&#224;y sinh" Width="100px" TabIndex="7" />
                <DatePopupButton TabIndex="7" />
            </radCln:RadDatePicker>
        </td>
        <td align="right">
            Thành phố:</td>
        <td>
            <asp:DropDownList ID="drCity" runat="server" Width="195px" TabIndex="15">
            </asp:DropDownList></td>
    </tr>
    <tr>
        <td align="right" valign="top">
            Thông tin thêm:</td>
        <td style="width: 255px;" rowspan="2" valign="top">
            <asp:TextBox ID="txtAdditionalInfo" runat="server" Width="250px" TextMode="MultiLine"
                Height="90px" TabIndex="8"></asp:TextBox></td>
        <td align="right" valign="top" id="tdTasdasdel" runat="server" visible="false">
            Địa chỉ:</td>
        <td align="left" valign="top" rowspan="2" id="tdTegggl" runat="server" visible="false"> 
            <asp:TextBox ID="txtAddress" runat="server" Width="250px" Height="90px" TextMode="MultiLine"
                TabIndex="16"></asp:TextBox></td>
    </tr>
    <tr>
        <td align="right" valign="top">
        </td>
        <td align="right">
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
            <asp:Button ID="btnCreate" ValidationGroup="groupuser" runat="server" SkinID="AdminButtonInsert"
                OnClick="btnCreate_Click" TabIndex="9" /></td>
        <td>
        </td>
        <td>
        </td>
    </tr>
</table>
